//
//  WNComposeButton.swift
//  XLWeibo
//
//  Created by 风不会停息 on 2017/7/30.
//  Copyright © 2017年 风不会停息. All rights reserved.
//

import UIKit

class WNComposeButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //图片居中等比显示
        imageView?.contentMode = .center
        //文字居中
        titleLabel?.textAlignment = .center
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //调整控件布局
    override func layoutSubviews() {
        //必须调用
        super.layoutSubviews()
        
        //  设置图片大小
        imageView?.frame.size.width = self.bounds.size.width
        imageView?.frame.size.height = self.bounds.size.width
        //  设置图片的y
        imageView?.frame.origin.y = 0
        
        titleLabel?.frame.size.width = self.bounds.size.width
        titleLabel?.frame.size.height = self.bounds.size.height - self.bounds.size.width
        //  设置label的y
        titleLabel?.frame.origin.y = self.bounds.size.width
        //  设置label的x
        titleLabel?.frame.origin.x = 0
        
        print(self.frame.size.width, self.frame.size.height)
        print(self.bounds.size.width, self.bounds.size.height)
    }
    
}
